package o;

import android.content.Context;
import android.text.TextUtils;
import androidx.annotation.NonNull;
import com.huawei.android.app.LocaleHelperEx;
import com.huawei.appgallery.foundation.account.bean.UserSession;
import java.util.ArrayList;
import java.util.Locale;
import o.dky.j;

public class eqp {
    private static String ˊ = "";

    @NonNull
    public static String ॱ() {
        String packageName = ContentManager.getInstant().getContext().getPackageName();
        if ("com.huawei.appmarket".equals(packageName) || "com.huawei.educenter".equals(packageName)) {
            packageName = ˋ();
        } else {
            packageName = "CN";
        }
        if (!bkz.ˊ(packageName).equals(ˊ)) {
            ˊ = packageName;
            Logger.ˎ("HomeCountryUtils", "getHomeCountry(): " + packageName);
        }
        return packageName;
    }

    @NonNull
    public static String ˊ() {
        return ˊ(ॱ());
    }

    private static String ॱ(String str) {
        Context ˋ = ContentManager.getInstant().getContext();
        if (str.equalsIgnoreCase("MK")) {
            return ˋ.getString(j.ʾ);
        }
        if (str.equalsIgnoreCase("HK")) {
            return ˋ.getString(j.ॱˎ);
        }
        if (str.equalsIgnoreCase("MO")) {
            return ˋ.getString(j.ʿ);
        }
        if (!str.equalsIgnoreCase("TW")) {
            return new Locale("", str).getDisplayCountry();
        }
        if ("tw".equalsIgnoreCase(dod.ˋ("hbc.country"))) {
            return new Locale("", str).getDisplayCountry();
        }
        return ˋ.getString(j.ˉ);
    }

    public static String ˊ(String str) {
        if (!dof.ˋ(str)) {
            String displayCountry;
            if (azc.ˎ().ॱ() >= 23) {
                try {
                    displayCountry = LocaleHelperEx.getDisplayCountry(new Locale(Locale.getDefault().getLanguage(), str), Locale.getDefault());
                } catch (Throwable e) {
                    Logger.ˋ("HomeCountryUtils", "getDisplayCountry Exception:", e);
                    displayCountry = ॱ(str);
                }
            } else {
                displayCountry = ॱ(str);
            }
            if (!dof.ˋ(displayCountry)) {
                return displayCountry;
            }
        }
        return "";
    }

    public static ArrayList<String> ˎ() {
        if (!bjx.ˎ) {
            return new ArrayList();
        }
        ArrayList<String> arrayList;
        try {
            arrayList = (ArrayList) bjz.ˏ(bjz.ˋ(bjz.ˎ("com.huawei.android.app.LocaleHelperEx"), "getBlackRegions", Context.class, Locale.class), null, ContentManager.getInstant().getContext(), Locale.getDefault());
        } catch (Exception e) {
            Logger.ˋ("HomeCountryUtils", "getBlackRegions error:" + e.toString());
            arrayList = null;
        }
        if (arrayList == null) {
            return new ArrayList();
        }
        return arrayList;
    }

    public static String ˋ() {
        Object homeCountry = UserSession.getInstance().getHomeCountry();
        return !TextUtils.isEmpty(homeCountry) ? homeCountry : ˏ();
    }

    public static String ˏ() {
        Object ˊॱ = epr.ˎ().ˊॱ();
        if (!TextUtils.isEmpty(ˊॱ)) {
            return ˊॱ;
        }
        if ("CN".equalsIgnoreCase(ˋॱ())) {
            return "CN";
        }
        String ͺ = ͺ();
        return TextUtils.isEmpty(ͺ) ? ˋॱ() : ͺ;
    }

    public static boolean ᐝ() {
        return "CN".equalsIgnoreCase(ॱ());
    }

    public static boolean ʻ() {
        return "RU".equalsIgnoreCase(ॱ());
    }

    public static boolean ʽ() {
        return "IR".equalsIgnoreCase(ॱ());
    }

    public static boolean ʼ() {
        return "CN".equalsIgnoreCase(ͺ());
    }

    public static boolean ॱॱ() {
        return "CN".equalsIgnoreCase(dod.ˋ("ro.product.locale.region"));
    }

    public static String ͺ() {
        String ˋ = dod.ˋ("ro.product.locale.region");
        if (dof.ˋ(ˋ)) {
            ˋ = dod.ˋ("ro.product.locale");
            if (!dof.ˋ(ˋ)) {
                Logger.ˏ("HomeCountryUtils", "ro.product.locale=" + ˋ);
                if (ˋ.contains("CN")) {
                    return "CN";
                }
            }
            int lastIndexOf = ˋ.lastIndexOf("-");
            if (lastIndexOf >= 0 && lastIndexOf + 1 < ˋ.length()) {
                ˋ = ˋ.substring(lastIndexOf + 1);
            }
            if (dof.ˋ(ˋ)) {
                return ˋ;
            }
            return ˋ.toUpperCase(Locale.US);
        }
        Logger.ˏ("HomeCountryUtils", "ro.product.locale.region=" + ˋ);
        return ˋ.toUpperCase(Locale.US);
    }

    @NonNull
    private static String ˋॱ() {
        String str = "";
        Locale locale = Locale.getDefault();
        if (locale == null) {
            return str;
        }
        str = locale.getCountry();
        if (str == null) {
            return "";
        }
        return str;
    }

    public static boolean ॱˊ() {
        if (TextUtils.isEmpty(UserSession.getInstance().getHomeCountry()) && TextUtils.isEmpty(epr.ˎ().ˊॱ()) && !"CN".equals(ॱ())) {
            return true;
        }
        return false;
    }
}
